package yu.liu.personal.app.myapplication.components;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;

import yu.liu.personal.app.myapplication.utils.ResourceManager;

/**
 * Created by Administrator on 2016/9/24.
 */

public abstract class ViewCollection {

    protected Context resContext;
    protected View contentView;
    protected ResourceManager resManager;

    public ViewCollection(Context context) {
        resContext = context;
        resManager = ResourceManager.getManager(resContext);
    }

    public View initView(@Nullable View parentView, int viewId) {
        if (resContext == null) {
            return null;
        }
        if (parentView == null) {
            contentView = LayoutInflater.from(resContext).inflate(viewId, null);
        } else {
            contentView = parentView.findViewById(viewId);
        }
        loadViews();
        return contentView;
    }

    protected abstract void loadViews();

    public abstract void updateViews();

    public View getContentView() {
        return contentView;
    }
}
